﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Components;
using Com.Seezt.Skins;
using System.Collections;
using UI.Lib.Factory;

namespace UI.ProductManagement
{
    public partial class FrmPot0a03 : UI.ParentForm.BaseMain
    {
        FrmPot0a03Edit edit = null;

        public FrmPot0a03(string modulecode, string action)
            : base(modulecode, action)
        {
            InitializeComponent();

            this.tspView.Visible = false;
        }

        protected override void OnAddClick(ToolStripButton btn)
        {
            edit = new FrmPot0a03Edit("A", GetTitleStyle(this.Text, btn.Text), "");
            edit.ShowDialog();
            if (edit.IsReload) base.BindGrid();
        }

        protected override void OnDeleteClick(ToolStripButton btn, DataGridViewRow row)
        {
            string listid = Validation.ToString(row.Cells["listid"].Value);
            if (string.IsNullOrEmpty(listid)) return;

            if (MsgBox.Show(this, "是否确定删除？", "是否确定删除？", MessageBoxButtons.YesNo)
                == DialogResult.Yes)
            {
                Hashtable tb = new Hashtable();
                tb["listid"] = listid;

                string errmsg = CommonHelper.Entity.Save("Pot0a03Manager$SaveData",
                     StringUtil.Entity.TableToJson(tb),
                    "D"); //调用服务器的保存方法

                bool isSuccess = string.IsNullOrEmpty(errmsg); // 是否保存成功
                if (!isSuccess) MsgBox.ShowErrorMsg(this, errmsg);
                else
                {
                    base.BindGrid();
                }
            }
        }

        protected override void UpdatePager(UI.Common.Pager pager)
        {
            pager.FilterAppName = "muser";
            pager.StrWhere = "status = '01'";
        }

    }
}
